<%@ page language="java" session="true" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<jsp:include page="../common/framework/header.jsp" />
<link href="${pageContext.request.contextPath}/static/plugin/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/static/css/testCase/corecss.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/static/plugin/coodo/coodo.bootstrap.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/static/css/nifty-demo-icons.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/static/css/testCase/addOrEditTestCase.css" rel="stylesheet">
<style></style>
	<div class="container-fluid"  id="bodyDiv">
    <form id ="testCaseForm" class="form-horizontal" enctype="multipart/form-data">
    	<div class="form-inline row  first-row-btns-div">
	    	<div class="form-group col-sm-12 first-row-btns-group">
	         		<a type="button" title="新建链接工作项" class="add_case first-row-btns" id="createLink" onclick="addOrEditTC_main.createLink();">
	         				<span class="icon icon-tfs-work-item-new-linked" ></span>
	         				新建链接
	         		</a>
	         		<a type="button" title="创建此工作项的副本(包括链接)" class="add_case first-row-btns" id="copyCase" onclick="addOrEditTC_main.copyCase();">
	         				<span class="icon icon-tfs-work-item-copy"></span>
	         				 克隆
	         		</a>
	         		<a type="button"  title="创建bug" onclick="addOrEditTC_main.createBug();" class="add_case first-row-btns first-row-btns-3" id="createBug">
	         				<span class="fa fa-bug" ></span>
	         				创建bug
	         		</a>
	         		<hr>
	         </div>
	     </div>
       	<div class="form-inline row">
	         <div class="form-group col-sm-12" >
				<input type="text" class="  form-control" id="name" name="name"  placeholder="请输入用例名称(必填项)">
	         </div>
	     </div>
	     <div class = "form-inline row form-table-rows" >
         	<div class="form-group col-sm-6 col-xs-6 form-table-rows-group0">
            	<label class="col-xs-2 form-table-rows-lable" >指派给:</label>
            	<div class="col-xs-10 define-formTable">
					<select class="selectpicker" title="请选择..." data-width="100%" id="assignId" name="assignId">
                    </select>
				</div>
         	</div>
         	<div class = "form-group col-sm-6 col-xs-6" >
            	<label class="col-xs-2 form-table-rows-lable">区域:</label>
            	<div class="col-xs-10 define-formTable">
					<select class="selectpicker"  title="请选择..." data-width="100%" id="areaId" name="areaId">
                    </select>
				</div>
			</div>
		</div>
		<div class = "form-inline row form-table-rows">
         	<div class="form-group col-sm-6 col-xs-6 form-table-rows-group0">
            	<label class="col-xs-2 form-table-rows-lable">状态:</label>
            	<div class="col-xs-10 define-formTable">
					<select class="selectpicker" title="请选择..." data-width="100%" id="state" name="state">
                        <option value="1" selected>1-就绪</option>
                        <option value="2">2-设计</option>
                        <option value="3">3-已关闭</option>
                    </select>
				</div>
         	</div>
         	<div class = "form-group col-sm-6 col-xs-6" >
            	<label class="col-xs-2 form-table-rows-lable">迭代:</label>
            	<div class="col-xs-10 define-formTable">
					<select class="selectpicker" title="请选择..." data-width="100%" id="iterationId" name="iterationId">
                    </select>
				</div>
			</div>
		</div>
		<div class = "form-inline row form-table-rows">
         	<div class="form-group col-sm-6 col-xs-6 form-table-rows-group0" >
            	<label class="col-xs-2 form-table-rows-lable">优先级别:</label>
            	<div class="col-xs-10 define-formTable">
					<select class="selectpicker" title="请选择..." data-width="100%" id="priority" name="priority">
                        <option value="1" selected>1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                    </select>
				</div>
         	</div>
         	<div class = "form-group col-sm-6 col-xs-6" >
            	<label class="col-xs-2 form-table-rows-lable">模块:</label>
            	<div class="col-xs-10 define-formTable">
					<select class="selectpicker"  title="请选择..." data-width="100%" id="moduleId" name="moduleId">
                    </select>
				</div>
			</div>
		</div>
		<div class = "form-inline row form-table-rows">
         	<div class="form-group col-sm-6 col-xs-6 form-table-rows-group0">
            	<label class="col-xs-2 form-table-rows-lable">测试方式:</label>
            	<div class="col-xs-10 define-formTable">
					<select class="selectpicker" title="请选择..." data-width="100%" id="executionType" name="executionType">
                        <option value="1" selected>手动</option>
                        <option value="2">自动</option>
                    </select>
				</div>
         	</div>
         	<div class = "form-group col-sm-6 col-xs-6" >
            	<label class="col-xs-2 form-table-rows-lable">摘要:</label>
            	<div class="col-xs-10 define-formTable">
					<input type = "text" class="  form-control"   placeholder="请输入"  id="summary" name="summary">
				</div>
			</div>
		</div>

		<input type ="hidden"   id="testcaseId" name="testcaseId">
		<input type ="hidden"   id="insertFlag" name="insertFlag">
		<input type ="hidden"   id="hierarchyId" name="hierarchyId">
		<input type ="hidden"   id="tcsteps" name="tcsteps">
		<input type = "text" class="hidden"   placeholder="请输入"  id="relations" name="relations">
		<input type = "text" class="hidden"   placeholder="请输入"  id="attachments" name="attachments">
		<div id ="attachmentHtml">
	         <div class="row">
		         <div class = "form-group col-sm-12 col-xs-12">
		            <label class="col-xs-2 define-lable"><font color=red>*</font>上传附件:</label>
		            <div class="col-xs-10  create_input">
<!-- 		            	<input type="file" class="  form-control" id="files" name="files"   class="file"  onchange="" multiple="multiple"> -->
		         	</div>
		         </div>
	         </div>
		</div>
    </form>

    <div class = "form-inline row tabs-row">
         	<div class="form-group col-sm-12 col-xs-12 tabs-row-group">
            		<div class="tab-base">

			            <ul class="nav nav-tabs">
			                <li class="active">
			                    <a data-toggle="tab" href="#demo-lft-tab-1">步骤</a>
			                </li>
			                <li>
			                    <a data-toggle="tab" href="#demo-lft-tab-2">所有链接</a>
			                </li>
			                <li>
			                    <a data-toggle="tab" href="#demo-lft-tab-3">附件</a>
			                </li>
			            </ul>

			            <div class="tab-content">
			                <div id="demo-lft-tab-1" class="tab-pane fade active in">
			                    <div class="panel">
									<div class="panel-heading">
										<div class ="panel-title">
									     		<a class="title_menu" type="button"  id="btninsertRow" title="插入步骤"><span class="icon icon-tfs-tcm-insert-step"></span></a>
									     		<a class="title_menu up" type="button"  title="上移当前步骤" ><span class="icon icon-up"></span></a>
									     		<a class="title_menu down" type="button"  title="下移当前步骤" ><span class="icon icon-arrow-down"></span></a>
									     		<a class="title_menu" type="button"   id="btndeleteRow" title="删除步骤"><span class="icon icon-delete"></span></a>
												<a class="btn btn-primary pull-right" id="btnappendRow" >
													<i class="fa fa-plus"></i> 添加步骤
												</a>
										</div>
									</div>
									<div class="panel-body pad-top-no">
										<div id="grid">
							                        <table id="stepTable"></table>
							            </div>
									</div>
								</div>
			                </div>
			                <div id="demo-lft-tab-2" class="tab-pane fade">
			                    <div class="panel">
									<div class="panel-heading">
										<div class ="panel-title">
									     		<a class="title_menu add_case" type="button" title="链接新工作项" onclick="addOrEditTC_main.createLink();" ><span class="icon icon-tfs-work-item-new-linked"></span></a>
									     		<a class="title_menu" type="button" title="链接已有工作项" onclick="addOrEditTC_relation.relateLink();"><span class="icon icon-tfs-link-add"></span></a>
									     		<a class="title_menu" type="button"  title="打开链接项" onclick="addOrEditTC_relation.openLink();"><span class="icon icon-open"></span></a>
									     		<a class="title_menu" type="button"  onclick="addOrEditTC_relation.deleteLinkRows();" id="delete" title="删除链接"><span class="icon icon-tfs-link-delete"></span></a>
										</div>
									</div>
									<div class="panel-body pad-top-no">
										<table id="linkTb"></table>
									</div>
								</div>
			                </div>
			                <div id="demo-lft-tab-3" class="tab-pane fade">
			                    <div class="panel">
									<div class="panel-heading">
										<div class ="panel-title">
									     		<a class="title_menu fileinput-button dz-clickable" type="button"  onclick="addOrEditTC_attachment.uploadAttachment();" id="insert" title="添加附件"><span class="icon icon-add"></span></a>
									     		<a class="title_menu" type="button"  title="下载附件" onclick="addOrEditTC_attachment.downloadFile();"><span class="icon icon-arrow-down"></span></a>
									     		<a class="title_menu" type="reset"  title="删除附件" onclick="addOrEditTC_attachment.delAttachmentRows();" id="dz-remove-btn"><span class="icon icon-delete"></span></a>
										</div>
									</div>
									<div class="panel-body pad-top-no">
											<table id="attachmentTable"></table>
									</div>
								</div>
			                </div>
			            </div>
			        </div>
         	</div>
		</div>
</div>

<div id ="createLinkHtml">
		<form id ="createLinkForm">
	         <label class="createLinkForm-lable">选择链接类型和详细信息。</label>
    		<div class="row createLinkForm-rows createLinkForm-rows0">
		         <div class = "form-group col-sm-12 col-xs-12">
		            <label class="col-xs-2 define-lable"><font color=red>*</font>链接类型:</label>
		            <div class="col-xs-10 define-formTable">
		            	<select class="form-control"   id="create_relationType"  name ="create_relationType"  ></select>
		         	</div>
		         </div>
	         </div>
	         <div class="row createLinkForm-rows">
		         <div class = "form-group col-sm-12 col-xs-12">
		            <label class="col-xs-2 define-lable">工作项类型:</label>
		            <div class="col-xs-10 define-formTable">
		            	<select class="form-control"   id="create_itemType"  name ="create_itemType"  >
		            		 <option value="1">CTS测试用例</option>
<!-- 		            		 <option value="2">jira issue</option> -->
		            	</select>
		         	</div>
		         </div>
	         </div>
	         <div class="row createLinkForm-rows">
		         <div class = "form-group col-sm-12 col-xs-12">
		            <label class="col-xs-2 define-lable"><font color=red>*</font>标题:</label>
		            <div class="col-xs-10 define-formTable">
		            	<input type="text" class=" form-control" id="create_name" name="create_name" placeholder = "请输入标题" >
		         	</div>
		         </div>
	         </div>
	    </form>
	</div>
	<div id ="cloneHtml">
		<form id ="cloneForm">
	         <label id="clone_lable"></label>
    		<div class="row cloneForm-rows cloneForm-rows0">
		         <div class = "form-group col-sm-12 col-xs-12">
		            <label class="col-xs-2 define-lable" ><font color=red>*</font>项目:</label>
		            <div class="col-xs-10 define-formTable">
		            	<select class="form-control"   id="projectId"  name ="projectId"onchange="addOrEditTC_hidden_clone.projectOnchange();"></select>
		         	</div>
		         </div>
	         </div>
	         <div class="row cloneForm-rows">
		         <div class = "form-group col-sm-12 col-xs-12">
		            <label class="col-xs-2 define-lable"><font color=red>*</font>测试计划:</label>
		            <div class="col-xs-10 define-formTable">
		            	<select class="form-control"   id="testplanId" name ="testplanId" onchange="addOrEditTC_hidden_clone.testPlanOnchange();"></select>
		         	</div>
		         </div>
	         </div>
	         <div class="row cloneForm-rows">
		         <div class = "form-group col-sm-12 col-xs-12">
		            <label class="col-xs-2 define-lable tree-select-lable">测试套件:</label>
		            <div class="define-formTable" >
		            <input type="text" class=" form-control" id="menu_parent_name" onfocus="this.blur()"placeholder="请选择测试套件">
					<input type="hidden" id="menu_id" name="menu_id">
		         	</div>
		         </div>
	         </div>
	         <div id="treediv"></div>
	    </form>
	</div>
	<div id ="relateLinkHtml">
		<form id ="relateLinkForm">
	         <label class="relateLinkForm-lable">选择链接类型和详细信息。</label>
    		<div class="row relateLinkForm-rows relateLinkForm-rows0">
		         <div class = "form-group col-sm-12 col-xs-12">
		            <label class="col-xs-2 define-lable"><font color=red>*</font>链接类型:</label>
		            <div class="col-xs-10 define-formTable">
		            	<select class="form-control"   id="relate_relationType"  name ="relate_relationType"  ></select>
		         	</div>
		         </div>
	         </div>
	         <div class="row relateLinkForm-rows">
		         <div class = "form-group col-sm-12 col-xs-12">
		            <label class="col-xs-2 define-lable">工作项类型:</label>
		            <div class="col-xs-10 define-formTable">
		            	<select class="form-control"   id="relate_itemType"  name ="relate_itemType"  onchange="addOrEditTC_hidden_relateLink.relate_itemType_onchange();">
		            		 <option value="1">CTS测试用例</option>
		            		 <option value="2">jira issue</option>
		            	</select>
		         	</div>
		         </div>
	         </div>
	         <div class="row relateLinkForm-rows">
		         <div class = "form-group col-sm-12 col-xs-12">
		            <label class="col-xs-2 define-lable"><font color=red>*</font>工作项:</label>
		            <div class="col-xs-10 define-formTable">
		            	<select class="form-control"   id="relate_workItem"  name ="relate_workItem"  ></select>
		         	</div>
		         </div>
	         </div>
	    </form>
	</div>
	<jsp:include page="../common/framework/script.jsp" />
	<script src="${pageContext.request.contextPath}/static/js/common/bootdatatable.init.js"></script>
	<script src="${pageContext.request.contextPath}/static/plugin/bootstrap-table/bootstrap-table.min.js"></script>
	<script src="${pageContext.request.contextPath}/static/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
	<script src="${pageContext.request.contextPath}/static/plugin/coodo/coodo.bootstrap.min.js"></script>
	<script src="${pageContext.request.contextPath}/static/js/common/dtreeck.js"></script>
	<script src="${pageContext.request.contextPath}/static/js/testCase/addOrEditTestCase.js"></script>
    <script type="text/javascript">
    var layerFlag = "";
    //给弹框添加回车提交事件
    $(function(){ 
    	$(document).keydown(function(event){ 
	    	if(event.keyCode==13){
	    		//禁用刷新页面
				window.event.returnValue = false;
	    		if(layerFlag == "relateLink"){//连接已有工作项弹框处于打开状态，则enter键触发该弹框的保存事件
	    			addOrEditTC_relation.saveRelateLink();
	    		}else if(layerFlag == "createLink"){//若为空，则触发新建/编辑保存事件
	    			addOrEditTC_main.saveCreateLink();
	    		}else if(layerFlag == "clone"){//若为空，则触发新建/编辑保存事件
	    			addOrEditTC_hidden_clone.copyCaseSubmit();
	    		}else if(layerFlag == ""){//若为空，则触发新建/编辑保存事件
	    			submit();
	    		}
	    	} 
    	}); 
    });
	$(function(){
		//表单验证
		 $('#testCaseForm').bootstrapValidator({
	   		   message: 'This value is not valid',
	           feedbackIcons: {
	        	   valid:'glyphicon glyphicon-ok',
	        	   invalid:'glyphicon glyphicon-remove',
	        	   validating:'glyphicon glyphicon-refresh'
	           },
	           excluded: [':disabled'],
	            fields: {
	            	name :{
						message : '用例名称验证失败',
						validators : {
							notEmpty : {//非空验证：提示消息
								message : '用例名称不能为空'
							},
							stringLength: {/*长度提示*/
							    min: 1,
							    max: 100,
							    message: '用例名称长度必须在1到100个字之间'
							   }
						}
					},
					summary :{
						message : '摘要验证失败',
						validators : {
							stringLength: {/*长度提示*/
							    min: 1,
							    max: 255,
							    message: '摘要长度必须在1到255个字之间'
							   }
						}
					}

	               }
	        });
		 
		 $('#createLinkForm').bootstrapValidator({
	   		   message: 'This value is not valid',
	           feedbackIcons: {
	        	   valid:'glyphicon glyphicon-ok',
	        	   invalid:'glyphicon glyphicon-remove',
	        	   validating:'glyphicon glyphicon-refresh'
	           },
	           excluded: [':disabled'],
	            fields: {
	            	create_relationType :{
						message : '链接类型验证失败',
						validators : {
							notEmpty : {//非空验证：提示消息
								message : '链接类型不能为空'
							}
						}
					},
	            	create_name :{
						message : '标题验证失败',
						validators : {
							notEmpty : {//非空验证：提示消息
								message : '标题不能为空'
							},
							stringLength: {/*长度提示*/
							    min: 1,
							    max: 100,
							    message: '标题长度必须在1到100个字之间'
							   }
						}
					}

	               }
	        });
		 
		 $('#relateLinkForm').bootstrapValidator({
	   		   message: 'This value is not valid',
	           feedbackIcons: {
	        	   valid:'glyphicon glyphicon-ok',
	        	   invalid:'glyphicon glyphicon-remove',
	        	   validating:'glyphicon glyphicon-refresh'
	           },
	           excluded: [':disabled'],
	            fields: {
	            	relate_relationType :{
						message : '链接类型验证失败',
						validators : {
							notEmpty : {//非空验证：提示消息
								message : '链接类型不能为空'
							}
						}
					},
					relate_workItem :{
						message : '工作项验证失败',
						validators : {
							notEmpty : {//非空验证：提示消息
								message : '工作项不能为空'
							}
						}
					}

	               }
	        });
		 
		 $('#cloneForm').bootstrapValidator({
	   		   message: 'This value is not valid',
	           feedbackIcons: {
	        	   valid:'glyphicon glyphicon-ok',
	        	   invalid:'glyphicon glyphicon-remove',
	        	   validating:'glyphicon glyphicon-refresh'
	           },
	           excluded: [':disabled'],
	            fields: {
	            	projectId :{
						message : '项目验证失败',
						validators : {
							notEmpty : {//非空验证：提示消息
								message : '项目不能为空'
							}
						}
					},
					testplanId :{
						message : '测试计划验证失败',
						validators : {
							notEmpty : {//非空验证：提示消息
								message : '测试计划不能为空'
							}
						}
					}
	               }
	        });
		})
    
    var currentProjectId = '${currentProjectId}';
    var tableName = "";
    var insertFlag = parent.insertFlag;
    $("#insertFlag").val(insertFlag);
    if(insertFlag == "testcase"){
    	$("#hierarchyId").val("");
    	tableName = "testCaseTable";
    }else if(insertFlag == "testplan"){
    	var nodeId = parent.nodeId;
    	//为套件ID
    	$("#hierarchyId").val(nodeId);
    	tableName = "testPlanTable";
    }
    var flag = parent.flag;
    var destinationId = '${destinationId}';
    var rowData = parent.$("#"+tableName).bootstrapTable('getData')[flag];
    var testcaseId = "";
  //destinationId不为空则为打开链接项的弹框，否则为编辑按钮弹框
    if(destinationId == ""){
    	if(parent.flag != -1){
    		testcaseId = rowData.testcaseId;
    	}
	 }else{
		   testcaseId = destinationId;
	 }
    //定义步骤信息的全局变量
    var data={};
    //定义所有链接信息的全局变量
    var data_links = [];
    //定义附件信息的全局变量
    var data_attachments = [];
    //初始化页面
    $(function () {
    	if(testcaseId != ""){
    		addOrEditTC_main.getTestCase();
    		addOrEditTC_main.getTestCaseRelation();
    		$("#testcaseId").val(testcaseId);
//     		if(parent.flag != -1){

//                 addOrEditTC_hidden_clone.listProject();
// //                 var projectId = $("#projectId").val();
// //                 addOrEditTC_hidden_clone.listTestPlan(projectId);
// //                 var testplanId = $("#testplanId").val();
// //                 addOrEditTC_hidden_clone.listTestSuite(testplanId);

//             }
    	}else{
        	addOrEditTC_main.insertCaseInitialCondition();
        	addOrEditTC_main.create_initGrid();
        }

//         addOrEditTC_hidden_relateLink.relate_itemType_onchange();
//         addOrEditTC_hidden_relateLink.relationTypeList();
//         addOrEditTC_main.initGrid();
        addOrEditTC_step.initMethod();
        if(parent.flag != -1){
    		if($('.add_case').hasClass('a_disabled')){
        		$('.add_case').removeClass('a_disabled');
        	}
        }else{
        	$('.add_case').addClass('a_disabled');
        }

    });

  //文件类型和大小的控制
    var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
    function fileChange(target,id) {
        var fileSize = 0;
//         var filetypes =[".xls",".xlsx"];
        var filepath = target.value;
        var filemaxsize = 1024*10;//10M
        if(filepath){
            var isnext = false;
            var fileend = filepath.substring(filepath.lastIndexOf("."));
//             if(filetypes && filetypes.length>0){
//                 for(var i =0; i<filetypes.length;i++){
//                     if(filetypes[i]==fileend){
//                         isnext = true;
//                         break;
//                     }
//                 }
//             }
//             if(!isnext){
// //	                alert("不接受此文件类型！");
//                 toast.info ('只接受".xls",".xlsx"类型的文件！','信息提示'); 
//                 target.value ="";
//                 return false;
//             }
        }else{
            return false;
        }
        if (isIE && !target.files) {
            var filePath = target.value;
            var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
            if(!fileSystem.FileExists(filePath)){
                toast.info ('附件不存在，请重新输入！','信息提示'); 
                return false;
            }
            var file = fileSystem.GetFile (filePath);
            fileSize = file.Size;
        } else {
            fileSize = target.files[0].size;
        }
        var size = fileSize / 1024;
        if(size>filemaxsize){
            toast.info ('附件大小不能大于'+filemaxsize/1024+'M！','信息提示'); 
            target.value ="";
            return false;
        }
        if(size<=0){
            toast.info ('附件大小不能为0M！','信息提示'); 
            target.value ="";
            return false;
        }
    }
    //新建编辑保存按钮触发
    function submit(){
    	var bootstrapValidator = $("#testCaseForm").data('bootstrapValidator').validate();
    	if(bootstrapValidator.isValid()){
    		if(parent.flag != -1){
        		addOrEditTC_main.updateSubmit();
        	}else{
        		addOrEditTC_main.createSubmit();
        	}
    	}
    }

    //获取当前时间，并规范时间格式
    Date.prototype.Format = function (fmt) { // author: meizz
	    var o = {
	        "M+": this.getMonth() + 1, // 月份
	        "d+": this.getDate(), // 日
	        "h+": this.getHours(), // 小时
	        "m+": this.getMinutes(), // 分
	        "s+": this.getSeconds(), // 秒
	        "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
	        "S": this.getMilliseconds() // 毫秒
	    };
	    if (/(y+)/.test(fmt))
	        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	    for (var k in o)
	        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
	            return fmt;
	}

    /*============== 树形结构下拉框开始================ */
	
	//生成弹出层的代码 
	<!-- 弹出层-->
	xOffset = 0;//向右偏移量
	yOffset = 190;//向下偏移量
	var toshow = "treediv";//要显示的层的id
	var target = "menu_parent_name";//目标控件----也就是想要点击后弹出树形菜单的那个控件id
	$("#"+target).click(function (){
		$("#"+toshow)
		.css("position", "absolute")
		.css("left", $("#"+target).position().left+xOffset + "px")
		.css("top", $("#"+target).position().top+yOffset +"px").show();
	});

	//判断鼠标在不在弹出层范围内
	 function   checkIn(id){
		var yy = 20;   //偏移量
		var str = "";
		var   x=window.event.clientX;   
		var   y=window.event.clientY;   
		var   obj=$("#"+id)[0];
		if(x>obj.offsetLeft&&x<(obj.offsetLeft+obj.clientWidth)&&y>(obj.offsetTop-yy)&&y<(obj.offsetTop+obj.clientHeight)){   
			return true;
		}else{   
			return false;
		}   
	  }   
	//点击body关闭弹出层
		$(document).click(function(){
			var is = checkIn("treediv");
			if(!is){
				$("#"+toshow).hide();
			}
		});
	<!-- 弹出层-->
	//生成弹出层的代码
	//点击菜单树给文本框赋值------------------菜单树里加此方法
	function setvalue(id,name){
		$("#menu_parent_name").val(name);
		$("#menu_id").val(id);
		$("#treediv").hide();
	}
	/*============== 树形结构下拉框结束================ */

    </script>
<jsp:include page="../common/framework/footer.jsp" />